package com.vonchange.utils.res.bean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
public class ResErrorReport implements ErrorReporter{
 private static Log logger =LogFactory.getLog(ResErrorReport.class);
    public void warning(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
        if (line < 0) {
        	logger.info("  " +sourceName+":"+ message);
        } else {
        	logger.info("  " +sourceName+":"+ line + ':' + lineOffset + ':' + message);
        }
    }

    public void error(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
        if (line < 0) {
        	logger.error("  " +sourceName+":" + message);
        } else {
        	logger.error("  " +sourceName+":"  + line + ':' + lineOffset + ':' + message);
        }
    }

    public EvaluatorException runtimeError(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
        error(message, sourceName, line, lineSource, lineOffset);
        return new EvaluatorException(message);
    }

}
